package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Curriculum;
import cn.wolfcode.crm.mapper.CurriculumMapper;
import cn.wolfcode.crm.query.CurriculumQueryObject;
import cn.wolfcode.crm.service.ICurriculumService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;


@Service
public class CurriculumServiceImpl implements ICurriculumService {
    @Autowired
    private CurriculumMapper curriculumMapper;


    @Override
    public PageResult getAll(CurriculumQueryObject qo) {
        int count = curriculumMapper.queryCount(qo);
        if (count == 0) {
            return new PageResult(0, Collections.EMPTY_LIST);
        }
        List<Curriculum> data = curriculumMapper.queryList(qo);
        return new PageResult(count, data);
    }

    @Override
    public void save(Curriculum curriculum) {
        curriculumMapper.insert(curriculum);
    }
}
